package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {
//    @Select("SELECT COUNT(*) FROM emp")
//    public Long count();
//    //进行分页查询获取数据的结果
//    @Select("SELECT * FROM emp LIMIT #{start},#{pageSize}")
//    public List<Emp> Page(Integer start, Integer pageSize);

    /*
    * 员工信息的查询
    * */
//    @Select("SELECT * FROM emp")
//    public List<Emp> list();

    /*
     员工信息的条件分页查询
     */

    public List<Emp> listCondition(String name, Short gender, LocalDate begin, LocalDate end);

    //批量删除员工
    //批量删除员工

    public void deleteByIds(List<Integer> ids);
    //新增员工
    @Insert("INSERT INTO emp(username,name,gender,image,job,entrydate,dept_id,create_time,update_time) VALUES(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);
//    @Update("UPDATE emp SET username=#{username},name=#{name},gender=#{gender},image=#{image},job=#{job},entrydate=#{entrydate},dept_id=#{deptId},create_time=#{createTime},update_time=#{updateTime} WHERE id=#{id}")
//    void update(Emp emp);
    @Select("SELECT * FROM emp WHERE id=#{id}")
    Emp getEmpById(Integer id);

    void addEmp(Emp emp);
    @Delete("DELETE FROM emp WHERE dept_id=#{id}")
    void deleteByDeptId(Integer id);
}
